import { titleConfig, iconConfig, splitLineConfig } from '../Global/global'

export default {
  ...titleConfig,
  ...splitLineConfig,
  ...iconConfig,
  updateTimeEnabled: {
    type: 'checkbox',
    title: '更新时间'
  },
  linkEnabled: {
    type: 'checkbox',
    title: '链接'
  },
  link: {
    when: (v) => v.linkEnabled,
    type: 'object',
    options: {
      url: {
        type: 'input',
        label: '链接地址'
      },
      tooltip: {
        type: 'input',
        label: '提示文字'
      },
      target: {
        type: 'select',
        label: '打开方式',
        defaultValue: 'blank',
        options: [
          { label: '新窗口', value: 'blank' },
          { label: '当前页', value: 'self' }
        ]
      }
    }
  },
  remarkEnabled: {
    type: 'checkbox',
    title: '备注'
  },
  remark: {
    when: (v) => v.remarkEnabled,
    type: 'object',
    options: {
      content: {
        type: 'textArea',
        label: '备注内容'
      },
      position: {
        type: 'radio',
        label: '展示位置',
        defaultValue: 'after',
        options: [
          { label: '图表上方', value: 'top' },
          { label: '紧跟标题', value: 'after' }
        ]
      }
    }
  },
  backgroundEnabled: {
    type: 'checkbox',
    title: '自定义背景填充',
    defaultValue: true
  },
  background: {
    when: (v) => v.backgroundEnabled,
    type: 'object',
    options: {
      color: {
        type: 'colorPicker',
        label: '背景颜色',
        defaultValue: '#fff'
      },
      backgroundImageEnabled: {
        type: 'checkbox',
        title: '背景图片'
      },
      backgroundImage: {
        when: (v) => v.backgroundImageEnabled,
        type: 'object',
        options: {
          url: {
            type: 'input',
            label: '图片链接'
          },
          layout: {
            type: 'select',
            label: '图片显示',
            defaultValue: 'fill',
            options: [
              { label: '居左平铺（比例不变，图片缩放）', value: 'contain-left' },
              { label: '居中显示（比例不变，图片缩放）', value: 'contain' },
              { label: '居右平铺（比例不变，图片缩放）', value: 'contain-right' },
              { label: '裁剪以充满区域（图片缩放，两头裁剪）', value: 'cover' },
              { label: '拉伸以充满区域（比例变化，图片缩放）', value: 'fill' }
            ]
          }
        }
      }
    }
  }
}
